#!ipxe

goto ${menu} ||

:live_menu
set os Ubuntu Live
menu ${os}
item --gap ${os} Versions
item jammy ${space} ${os} 22.04
item focal ${space} ${os} 20.04
choose live_version || goto live_exit
menu ${os} ${live_version}
item --gap ${os} Flavors
goto ${live_version}

:jammy
{% for key, value in endpoints.items() | sort %}
{% if value.os == "ubuntu" and 'squash' in key and value.version == "22.04" %}
item {{ key }} ${space} {{ value.os | title }} {{ value.version }} {{ value.flavor | title }}
{% endif %}
{% endfor %}
goto flavor_select

:focal
{% for key, value in endpoints.items() | sort %}
{% if value.os == "ubuntu" and 'squash' in key and value.version == "20.04" %}
item {{ key }} ${space} {{ value.os | title }} {{ value.version }} {{ value.flavor | title }}
{% endif %}
{% endfor %}
goto flavor_select

:flavor_select
choose flavor || goto live_menu
echo ${cls}
goto ${flavor} ||

{% for key, value in endpoints.items() | sort %}
{% if value.os == "ubuntu" and 'squash' in key %}
{% set kernel_name = value.kernel %}
:{{ key }}
set squash_url ${live_endpoint}{{ value.path }}filesystem.squashfs
{% for key, value in endpoints.items() | sort %}
{% if key == kernel_name %}
set kernel_url ${live_endpoint}{{ value.path }}
{% endif %}
{% endfor %}
goto {{ value.version }}-boot
{% endif %}
{% endfor %}

:20.04-boot
:22.04-boot
imgfree
kernel ${kernel_url}vmlinuz ip=dhcp boot=casper netboot=url url=${squash_url} {{ kernel_params }}
initrd ${kernel_url}initrd
boot

:live_exit
clear menu
exit 0
